<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数优化</title>
</head>
<body>


    <script>

        function aa(a,b=1){
            console.log(a+b);
        }

        aa(1)
    function add(...values){
        let sum = 0;
        for(var i=0;i<values.length;i++){
            sum+=values[i];
        }
        console.log(sum)
    }

    add(1,2)
    add(2,3,4,5,6,7,8)
    </script>
    
</body>
</html>